//
// Created by ole on 24-8-18.
//

#ifndef IPCPROXY_H
#define IPCPROXY_H
#include "IPCStrategyLocal.h"
#include "../../utils/Log.h"

class IPCProxy final : public IPCStrategy {
public:
    ~IPCProxy() override = default;

    std::string TAG = "IPCProxy";

    bool start() override {
        Log::i(TAG, "Starting.");
        return _strategy->start();
    }

    bool stop() override {
        Log::i(TAG, "Stopping.");
        return _strategy->stop();
    }

    void subscribe(const std::shared_ptr<Topic> &topic, const std::shared_ptr<MessageReceiver> &receiver) override {
        _strategy->subscribe(topic, receiver);
    }

    void unsubscribe(const std::shared_ptr<Topic> &topic, const std::shared_ptr<MessageReceiver> &receiver) override {
        _strategy->unsubscribe(topic, receiver);
    }

    void publishMessage(const std::shared_ptr<Message> &msg) override {
        _strategy->publishMessage(msg);
    }

    void loopForever() override {
        _strategy->loopForever();
    }

private:
    const std::shared_ptr<IPCStrategy> _strategy = std::make_shared<IPCStrategyLocal>();
};


#endif //IPCPROXY_H
